# !/usr/bin/env python
# encoding=utf-8

# 在Python中，这种一边循环一边计算的机制，称为生成器（Generator）
def generator1():
    print "hello"
    yield 1
    print "word"
    yield 2
    print "kitty"
    yield 3


def generator2():
    g = (x * x for x in range(10))
    print g.next()
    print g.next()


if __name__ == '__main__':
    g = generator1()
    g.next()
    g.next()
    g.next()
    print "-" * 60
    generator2()
